import {createRouter, createWebHashHistory, createWebHistory} from 'vue-router'
import { useHandleRouter } from "@/hooks/useHandleRouter";
// @ts-ignore
const routes = [
    {
        path: '/',
        // 路由重定向
        redirect: '/login'
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('../views/login/index.vue'),
    },
    {
        path: '/home',
        name: 'home',
        component: () => import('../views/home/home.vue'),
    },
    {
        path: '/websocket',
        name: 'websocket',
        component: () => import('../views/websocket/index.vue'),
    },
    {
        path: '/tables',
        name: 'tables',
        component: () => import('../views/tables/index.vue'),
    },
    {
        path: '/mouse',
        name: 'mouse',
        component: () => import('../views/mouse/index.vue'),
    },
    {
        path: '/select',
        name: 'select',
        component: () => import('../views/select/index.vue'),
    },
    {
        path: '/sealedTable',
        name: 'sealedTable',
        component: () => import('../views/sealedTable/index.vue'),
    },
    {
        path: '/dialog',
        name: 'dialog',
        component: () => import('../views/dialog/index.vue'),
    },
    {
        path: '/dynamicRows',
        name: 'dynamicRows',
        component: () => import('../views/dynamicRows/index.vue'),
    },
    {
        path: '/validate',
        name: 'validate',
        // @ts-ignore
        component: () => import('../views/validate/index.vue'),
    },
    {
        path: '/editor',
        name: 'editor',
        // @ts-ignore
        component: () => import('../views/editor/index.vue'),
    },
    {
        path: '/echart',
        name: 'echart',
        component: () => import('../views/echart/index.vue'),
    },
    {
        path: '/other',
        name: 'other',
        component: () => import('../views/other/index.vue'),
    },
    {
        path: '/Cylinder',
        name: 'Cylinder',
        component: () => import('../views/Cylinder/index.vue'),
    },
    {
        path: '/tabledeful',
        name: 'tabledeful',
        component: () => import('../views/tabledeful/index.vue'),
    },
]

const router = createRouter({
    history: createWebHistory(),
    scrollBehavior(_to, _from, savedPosition) {
        if (savedPosition) {
            return savedPosition;
        } else {
            return { top: 0 };
        }
    },
    routes,
})

// useHandleRouter(router);
export default router
